package com.mfl.controller.user;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.pojo.dto.KYCourseBookPageQueryDTO;
import com.mfl.pojo.entity.KYCourseVideo;
import com.mfl.pojo.vo.KYCourseBookVO;
import com.mfl.pojo.vo.KYCourseVideoVO;
import com.mfl.service.KYCourseBookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("userCourseBookController")
@RequestMapping("/cky/user/courseBook")
@Slf4j
public class CourseBookController {

    @Autowired
    private KYCourseBookService kyCourseBookService;

    /**
     * 分页查询课程图书
     * @param kyCourseBookPageQueryDTO
     * @return
     */
    @GetMapping("/pageQueryCourseBook")
    public Result<PageResult> pageQueryCourseBook(KYCourseBookPageQueryDTO kyCourseBookPageQueryDTO){
      log.info("分页查询课程图书：{}", kyCourseBookPageQueryDTO);
      PageResult pageResult = kyCourseBookService.pageQuery(kyCourseBookPageQueryDTO);
      return Result.success("", pageResult);
    }

    /**
     * 根据id查询课程书籍
     * @param id
     * @return
     */
    @GetMapping("/getCourseBookById")
    public Result<KYCourseBookVO> getCourseBookById(int id){
        log.info("根据id查询课程书籍：{}", id);
        KYCourseBookVO kyCourseBookVO = kyCourseBookService.getCourseBookById(id);
        return Result.success("", kyCourseBookVO);
    }
}
